<?php
/**
 * 用户模块
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2020/3/1
 * Time: 15:52
 */

namespace app\user\admin;

use app\system\admin\Admin;
use app\common\model\User as UserModel;
class User extends Admin
{
    /**
     * 用户列表
     * @return \think\response\View
     */
    public function list()
    {
        if ($this->request->isAjax()) {
            $where      = $data = [];
            $page       = $this->request->param('page/d', 1);
            $limit      = $this->request->param('limit/d', 15);
            $keyword    = $this->request->param('keyword/s');
//            $where[]    = ['id', 'neq', 1];
//            if ($keyword) {
//                $where[] = ['username', 'like', "%{$keyword}%"];
//            }

            $data['data'] = UserModel::with('info')->page($page)->limit($limit)->select();

            $data['count'] = UserModel::where($where)->count('id');
            $data['code'] = 0;
            $data['msg'] = '';
            return json($data);
        }

        $assign = [];
//        $assign['hisiTabData'] = $this->tabData;
//        $assign['hisiTabType'] = 3;

        return $this->assign($assign)->fetch();
    }

    /**
     * 实名认证
     */
    public function examine()
    {
        if ($this->request->isAjax()) {

            $where      = $data = [];
            $id       = $this->request->param('id');

            $status = UserModel::status($id,3);

            $data = ['code'=>1];

            if($status['code'] == 0){
                $data = ['code'=>0];
            }

            return $data;
        }
        $id       = $this->request->param('id');

        $whre = [
            'id'=>$id
        ];

        $userinfo = UserModel::with('info')->where($whre)->find();

        $this->assign('userinfo',$userinfo);

        return $this->fetch();
    }


    public function delUser()
    {
        $value = app('rquest')->only(['id']);

        UserModel::destroy($value['id']);

        return ;
    }
}